package com.business.user;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import com.sql.DBFactory;
import com.util.TextTools;

public class BlogInfo {

    private Connection conn=null;
    private Statement stmt=null;
    private ResultSet rs=null;
    private String sql;
    TextTools TT=new TextTools();
    int count=0;
    public int getUserCount()
    {
            sql=
                    "SELECT count(*) as total FROM user_login";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }
    public int getLogCount()
    {
            sql=
                    "SELECT count(*) as total FROM log_info";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }
    public int getLogReplyCount()
    {
            sql=
                    "SELECT count(*) as total FROM log_reply";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }
    public int getFavorCount()
    {
            sql=
                    "SELECT count(*) as total FROM log_favorite";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }

    public int getPhotoCount()
    {
            sql=
                    "SELECT count(*) as total FROM photo_detail";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }
    public int getMusicCount()
    {
            sql=
                    "SELECT count(*) as total FROM music_info";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }

    public int getPhotoTypeCount()
    {
            sql=
                    "SELECT count(*) as total FROM photo_type";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }
    public int getMusicTypeCount()
    {
            sql=
                    "SELECT count(*) as total FROM music_type";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }
    public int getTagCount()
    {
            sql=
                    "SELECT count(*) as total FROM log_tag";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }

    public int getLinkCount()
    {
            sql=
                    "SELECT count(*) as total FROM link";
            try
            {
                    conn=DBFactory.getConnection();
                    stmt=conn.createStatement();
                    rs=stmt.executeQuery(sql);
                    if(rs.next())
                    {
                            count=rs.getInt("total");
                    }
                    rs.close();
                    stmt.close();
                    conn.close();
            }
            catch(Exception e)
            {
                    System.out.println(e.toString());
            }
            return count;
    }

}
